<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="mini" v-show="showSearch" label-width="68px">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-form-item label="保险单号" prop="insuranceOdd">
            <el-input v-model="queryParams.insuranceOdd" placeholder="请输入" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="项目名称" prop="projectName">
            <el-input v-model="queryParams.projectName" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="员工姓名" prop="staffName">
            <el-input v-model="queryParams.staffName" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="保险状态" prop="insuranceStatus">
            <el-input v-model="queryParams.insuranceStatus" placeholder="请输入" clearable
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label-width="10px">
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table v-loading="loading" :data="insuranceList" border>
      <el-table-column label="项目区域" align="center" prop="projectRegion">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cld_project_region" :value="scope.row.projectRegion" />
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" prop="projectName" />
      <el-table-column label="员工姓名" align="center" prop="staffName" />
      <el-table-column label="身份证号" align="center" prop="staffIdcard" />
      <el-table-column label="银行卡号" align="center" prop="bankCard" />
      <el-table-column label="电话" align="center" prop="staffPhone" />
      <el-table-column label="保险名称" align="center" prop="insuranceName" />
      <el-table-column label="保险单号" align="center" prop="insuranceOdd" />
      <el-table-column label="保险到期时间" align="center" prop="endTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="保单状态" align="center" prop="insuranceStatus">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.insuranceStatus == 1" type="success">在保中</el-tag>
          <el-tag v-if="scope.row.insuranceStatus == 2" type="danger">已过期</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="保险状态" align="center" prop="staffInsuranceStatus">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.staffInsuranceStatus == 1" type="danger">已报案</el-tag>
          <el-tag v-if="scope.row.staffInsuranceStatus == 2" type="info">已出险</el-tag>
          <el-tag v-if="scope.row.staffInsuranceStatus == 3">已结案</el-tag>
          <el-tag v-if="scope.row.staffInsuranceStatus == 4" type="warning">已撤案</el-tag>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { insuranceStatistics } from "@/api/cld/insurance";


export default {
  name: "statics",
  dicts: ['cld_project_region'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 保险管理表格数据
      insuranceList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        insuranceOdd: null,
        insuranceStatus: null,
        projectName: null,
        staffName: null
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询保险管理列表 */
    getList() {
      this.loading = true;
      insuranceStatistics(this.queryParams).then(response => {
        this.insuranceList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
<style scoped>
.el-range-editor.el-input__inner {
  width: 100%;
}
</style>
